 *********** Final Do file needed for submission and replication
 
Title: Where are the Sore Losers? Competitive Authoritarianism, Incumbent Defeat, and Electoral Trust in Zambia’s 2021 Election
Running Header
Where are the Sore Losers?
Author affiliations:
Nicholas Kerr, Assistant Professor, Department of Political Science, University of Florida in Gainesville, Fl, US 
Matthias Krönke, Researcher, Institute for Democracy, Citizenship and Public Policy in Africa, University of Cape Town, South Africa.
Michael Wahman, Associate Professor, Department of Political Science, Michigan State University, East Lansing, MI, US. 
Corresponding author:
Michael Wahman, Michigan State University, 342 S. Kedzie Hall, 368 Farm Lane, East Lansing MI 48823, 517-353-7230; email: wahmanmi@msu.edu.
 

***** Coding Using Stata 14
***** ***** ***** ***** *****


***Change election quality (R3-R2)

recode q38_R2 (1=3) (2=2) (3=1) (4=0) (5/6=.), gen(EQ_PRES_POS_R2)
recode q74_R3  (1=3) (2=2) (3=1) (4=0) (5/6=.), gen(EQ_PRES_POS_R3)

label define EQ_PRES_POS 0 "Not free and fair" 1 "Free and fair with major problems" 2 "Free and fair, but with minor problems" 3 "Completely free and fair"
label val EQ_PRES_POS_R1 EQ_PRES_POS_R2 EQ_PRES_POS_R3 EQ_PRES_POS

gen EQ_PRES_CHG_R2_R3 = EQ_PRES_POS_R3  - EQ_PRES_POS_R2

***Vote Intentions (R2)

recode q35_R2 (8=0 "UPND") (6=1 "PF") (1 2 3 4 5  7  10 11 12 13 14= 2 "Others") (15 16 17 18 19= 3 "Abstain")  ,gen(VOTE_CH_R2_PRES)

***Strength of Party Affiliation (R2)

recode q40_R2 (12/13=.) ,gen(PART_R2_UPND)
recode q41_R2 (12/13=.) ,gen(PART_R2_PF)
gen PART_R2_COMB = PART_R2_UPND - PART_R2_PF

recode PART_R2_COMB  (-10/-4=3 "Strong PF") (-3/-1=2 "Weak PF") (0=4 "Neutral") (1/3=1 "Weak UPND") (4/10=0 "Strong UPND") (.=5 "Missing") , gen (PART_R2_COMB_5_CAT_R)

***Age (R1)
gen AGE = demo_q3_R2 

***Female (R1)

recode demo_q4_R2 (1=0 "Male") (2=1 "Female"), gen (FEMALE)


***Education (R1)
replace EDU = Q_109_R1 if demo_q26_R2 ==. 
replace EDU = demo_q26_R2 if EDU ==. 
label val EDU Q_109_R1

recode EDU (11=.), gen (EDU_R)
label val EDU_R Q_109_R1

***Urban/Peri-Urban Resident (R1)
gen URBAN =.
replace URBAN = demo_q12_R2
replace URBAN = Q_27_R1 if URBAN ==.
label val URBAN Q_27_R1

recode URBAN (3=0 "Rural") (1/2=1 "Urban/Peri") (4=.) , gen (URBAN_R)


***EC Procedural Capacity Index (6items) (R3)

recode q64_R3 (1=0) (2=1) (3=2) (4=3) (5/6=.), gen(q64_R3_R)
recode q65_R3 (1=0) (2=1) (3=2) (4=3) (5/6=.), gen(q65_R3_R)
recode q66_R3 (1=0) (2=1) (3=2) (4=3) (5/6=.), gen(q66_R3_R)
recode q67_R3 (1=0) (2=1) (3=2) (4=3) (5/6=.), gen(q67_R3_R)
recode q68_R3 (1=0) (2=1) (3=2) (4=3) (5/6=.), gen(q68_R3_R)
recode q69_R3 (1=0) (2=1) (3=2) (4=3) (5/6=.), gen(q69_R3_R)


label define PRC_CAP 0 "Not at all satisfied" 1 "Not very satisfied" 2 "Fairly satisfied" 3 "Very satisfied"
label val q64_R3_R q65_R3_R q66_R3_R q67_R3_R q68_R3_R q69_R3_R PRC_CAP

alpha q64_R3_R q65_R3_R q66_R3_R q67_R3_R q68_R3_R q69_R3_R

gen PRC_CAP = q64_R3_R + q65_R3_R + q66_R3_R + q67_R3_R + q68_R3_R + q69_R3_R

foreach v of var PRC_CAP {   
su `v', meanonly
 gen `v'_R = (`v' - r(min))/(r(max) - r(min))
 }

***Fear Violence (R2)
recode q57_R2 (1=0 "Not at all") (2=1 "A little bit") (3=2 "Somewhat") (4=3 "A lot") (5/6=.) , gen(FEAR_VIOL)

***Know MP (R1)
recode demo_q31_R2 (1=1 "YES") (2/3=0 "NO") (4=.), gen (KNOW_MP)


***Poor Government economic Performance (R2)
recode q5_R2 (2=0 "Good Econ. Man") (1=1 "Bad Econ. Man") (3/4=.), gen (BAD_ECON_MANAGE)

***** Regression Models (Tables and Figures )
***** ***** ***** ***** *****

**** Table 2: Regression analysis | change in perceptions of election quality 

*Model 2A
reg EQ_PRES_CHG_R2_R3  ib1.VOTE_CH_R2_PRES_3cat 
estimates store Model_2a

*Model 2B
reg EQ_PRES_CHG_R2_R3  ib1.VOTE_CH_R2_PRES_3cat PRC_CAP_R  FEAR_VIOL KNOW_MP AGE FEMALE EDU_R URBAN_R POVERTY_R 
estimates store Model_2b

* Table 2
quietly  outreg2 [  Model_2a Model_2b ] using Table_2 , excel lab side pvalue pdec(3) bdec(3) noaster replace

** Figure 4: Figure 4: Predicted mean change in election quality perceptions | by intended vote choice
	margins VOTE_CH_R2_PRES_3cat,  atmeans
	marginsplot, graphregion(fcolor(white)) recast(scatter) plotregion(fcolor(white)) ytitle (Mean Change in Election Quality Perceptions R2-3) legend(off)  yline(0, lcolor(red)) yscale(range(-0.5 (.5) 2)) ylabel(0 .5 1 1.5) title ("")
	graph save Model_2b, replace
	graph export Model_2b.pdf, replace

**** Appendix 

**** Table C4: Regression analysis | change in perceptions of election quality (Ordered Logit)

ologit EQ_PRES_CHG_R2_R3  ib1.VOTE_CH_R2_PRES_3cat PRC_CAP_R  FEAR_VIOL KNOW_MP AGE FEMALE EDU_R URBAN_R POVERTY_R 
estimates store Model_RB1
quietly outreg2 [  Model_RB1 ] using Table_C4 , excel lab side pvalue pdec(3) bdec(3) noaster replace


****Table C5: Regression analysis | change in perceptions of election quality (clustered standard errors: constituency)

reg EQ_PRES_CHG_R2_R3  ib1.VOTE_CH_R2_PRES_3cat PRC_CAP_R  FEAR_VIOL KNOW_MP AGE FEMALE EDU_R URBAN_R POVERTY_R, vce(clus const_r1_R2)
estimates store Model_RB2
quietly outreg2 [  Model_RB2 ] using Table_C5 , excel lab side pvalue pdec(3) bdec(3) noaster replace

****Table C6:  Regression analysis | change in perceptions of election quality (R2 election quality measure included)

reg EQ_PRES_CHG_R2_R3 EQ_PRES_POS_R2  ib3.PART_R2_COMB_5_CAT_R2 PRC_CAP_R  FEAR_VIOL KNOW_MP AGE FEMALE EDU_R URBAN_R POVERTY_R 
estimates store model_6e
quietly outreg2 [  model_6e] using model_6e , excel lab  onecol alpha(0.01, 0.05, 0.1) symbol(***, **, *) replace


****Figure C2: Predicted mean changes in election quality perceptions (R3-R2) by intended vote choice (R2 election quality measure included)

estimates restore model_6e
	margins PART_R2_COMB_5_CAT_R2,  atmeans
	marginsplot, graphregion(fcolor(white)) recast(scatter) plotregion(fcolor(white)) ytitle (Mean Change in Election Quality Perceptions) legend(off)  yline(0, lcolor(red)) yscale(range(-0.5 (.5) 2)) ylabel(0 .5 1 1.5) title ("")
	graph save model_6e, replace
	graph export model_6e.pdf, replace

****Table C7:  Regression analysis | perceptions of election quality R3 (R2 election quality measure included)

reg EQ_PRES_POS_R3 EQ_PRES_POS_R2  ib1.VOTE_CH_R2_PRES_3cat 
estimates store model_7a

reg EQ_PRES_POS_R3 EQ_PRES_POS_R2 ib1.VOTE_CH_R2_PRES_3cat PRC_CAP_R  FEAR_VIOL KNOW_MP AGE FEMALE EDU_R URBAN_R POVERTY_R 
estimates store model_7b
quietly outreg2 [  model_7a model_7b ] using Table_C7 , excel lab side pvalue pdec(3) bdec(3) noaster replace


****Figure C3: Predicted mean election quality perceptions (R3) by intended vote choice (R2 election quality measure included)

	margins VOTE_CH_R2_PRES_3cat,  atmeans
	marginsplot, graphregion(fcolor(white)) recast(scatter) plotregion(fcolor(white)) ytitle (Mean Election Quality Perceptions R3) legend(off)  yline(0, lcolor(red)) yscale(range(0.5 (.5) 3)) ylabel(0 .5 1 1.5 2.0 2.5 3.0) title ("")
	graph save model_7b, replace
	graph export model_7b.pdf, replace
	

****Table C8: Regression analysis | change in perceptions of election quality (strength of party affiliation)

reg EQ_PRES_CHG_R2_R3  ib3.PART_R2_COMB_5_CAT_R2 PRC_CAP_R  FEAR_VIOL KNOW_MP AGE FEMALE EDU_R URBAN_R POVERTY_R 
estimates store Model_2e
quietly outreg2 [  Model_2e] using Table_C8 , excel lab side pvalue pdec(3) bdec(3) noaster replace

****Figure 5: Predicted mean change in election quality perceptions | by strength of partisanship 
	estimates restore Model_2e
	margins PART_R2_COMB_5_CAT_R2,  atmeans
	marginsplot, graphregion(fcolor(white)) recast(scatter) plotregion(fcolor(white)) ytitle (Mean Change in Election Quality Perceptions) legend(off)  yline(0, lcolor(red)) yscale(range(-0.5 (.5) 2)) ylabel(0 .5 1 1.5) title ("")
	graph save Model_2e, replace
	graph export Model_2e.pdf, replace
	

****Table C9: Regression analysis | change in perceptions of election quality (R2 government economic performance included)

reg EQ_PRES_CHG_R2_R3  ib1.VOTE_CH_R2_PRES_3cat PRC_CAP_R  FEAR_VIOL KNOW_MP AGE FEMALE EDU_R URBAN_R POVERTY_R BAD_ECON_MANAGE
estimates store Model_10a

quietly outreg2 [  Model_10a] using Table_C9 , excel lab side pvalue pdec(3) bdec(3) noaster replace
